package com.boilerCloud.dao.sys.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.boilerCloud.dao.BaseDao;
import com.boilerCloud.dto.HzlqswPage;
import com.boilerCloud.dto.sys.AppVersion;
import com.boilerCloud.dto.sys.Dictionary;
import com.boilerCloud.util.StringUtil;
@Repository
public class AppVersionDao extends BaseDao {

	public void qryList(AppVersion model, HzlqswPage<AppVersion> page)throws Exception {

		String countsql = "select count(*) from dictionary a "
				+ " where a.is_delete='n' ";
			
		String listSql = "select a.* "
					+ " from dictionary a "
					+ " where a.is_delete='n' ";
		List<Object> params= new ArrayList<Object>();
		if(!StringUtil.isEmpty(model.getName())){
			countsql += " and a.name like ?";
			listSql += " and a.name like ?";
			params.add("%" + model.getName() +"%");
		}
		/*if(model.getType() != 0 && model.getType()!= -1){
			countsql += " and a.type= ?";
			listSql += " and  a.type= ?";
			params.add(model.getType() );
		}*/
			
		listSql += " order by id desc ";
		this.queryListByPage(countsql, params, listSql, params, page, AppVersion.class);
	}

	public void save(AppVersion model) {
		String sql = "insert into dictionary(type,name,code,keyword,remark,attachment,is_delete) "
				+ "values(?,?,?,?,?,?,'n')";
		List<Object> param = new ArrayList<Object>();
		/*param.add(model.getType());
		param.add(model.getName());
		param.add(model.getCode());
		param.add(model.getKeyword());
		param.add(model.getRemark());
		param.add(model.getAttachment());*/
		this.jdbcTemplate.update(sql,param.toArray());
		
	}

	public void edit(AppVersion model) {
		
		
	}

	public void del(int id) {
		String sql = "update dictionary set is_delete='y' where id=?";
		this.jdbcTemplate.update(sql,id);
		
	}

	

}
